<%@page language="java" import="com.scalar.chiptrack.finance.purchaseorder.PurchaseOrder,
                                com.scalar.chiptrack.utils.StringUtils,
                                com.scalar.chiptrack.finance.purchaseorder.PurchaseOrderLineItem" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<%@ page import="com.scalar.chiptrack.utils.ConfigManager"%>

<% int i = 0; /*variable used to assign numers to marketing part number drop down*/ %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html:html>
<HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<chiptrack:checkLogon sourcePage="purchaseOrder.do"/>

<META http-equiv='Content-Type' content='text/html; charset=windows-1252'>
<LINK href='<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css' type='text/css' rel='stylesheet'>

<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js">
</script>

<SCRIPT language='JavaScript'>

function savePO()
{

    if(typeof document.purchaseOrderForm['purchaseOrder.poHold'] != "undefined" )
    {
        document.purchaseOrderForm['purchaseOrder.poHold'].disabled=false;
    }
    var form = document.purchaseOrderForm;
    var count = document.purchaseOrderForm.count.value;

	// Po Lineitem cancel Field.
    for( i = 0; i < count; i++ )
    {
		form['purchaseOrder.purchaseOrderLineItemList[' + i + '].cancel'].disabled=false;
	}
    document.purchaseOrderForm.action.value="save";
    document.purchaseOrderForm.submit();
}

function editPO()
{
    if(typeof document.purchaseOrderForm['purchaseOrder.poHold'] != "undefined" )
    {
        document.purchaseOrderForm['purchaseOrder.poHold'].disabled=false;
    }
    var form = document.purchaseOrderForm;
    var count = document.purchaseOrderForm.count.value;

	// Po Lineitem cancel Field.
    for( i = 0; i < count; i++ )
    {
		form['purchaseOrder.purchaseOrderLineItemList[' + i + '].cancel'].disabled=false;
	}

    document.purchaseOrderForm.action.value="editConfirm";
    document.purchaseOrderForm.submit();
}


</SCRIPT>
</HEAD>
<BODY bgColor='#ffffff' leftMargin='0' topMargin='0' marginheight='0' marginwidth='0'>
<!-- Top Header Start-->

<%@include file="/jsp/includes/header.jsp"  %>
<!-- Top Header End-->
<p>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
	<TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<!-- Side Navigation start -->

<%@include file="/jsp/finance/purchase_order_menu.jsp" %>

</TD>
<!-- end of the side navigations -->

<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">

<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>
<!-- from here your body starts -->
			<P>

			<TABLE BORDER="0" WIDTH="100%">

				<TR>
					<TD WIDTH="100%">
            <html:form name="purchaseOrderForm" action="/purchaseOrder.do" method="post" type="com.scalar.chiptrack.finance.purchaseorder.forms.PurchaseOrderForm">
            <input type= "hidden" name = "action" value="">
            <input type="hidden" name="statusType" value="<%= request.getParameter("statusType") %>">
            <TABLE BORDER="0" WIDTH="100%" HEIGHT="175%">
				<TR>
					<TD WIDTH="100%">
						<TABLE BORDER="0" WIDTH="100%">
							<TR>
								<TD WIDTH="100%" class="NArialW">
									<P ALIGN="CENTER">Confirm Purchase Order
                                </TD>
							</TR>
						</TABLE>
                        <BR>
						<BR>
                        <nested:nest property="purchaseOrder">
						<TABLE BORDER="0" WIDTH="100%" CLASS="NArialL">
							<TR>
								<TD WIDTH="3%">&nbsp;</TD>
								<TD WIDTH="17%">PO Number:</TD>
								<TD WIDTH="1%">&nbsp;</TD>
								<TD WIDTH="31%">
                                    <nested:write property="poNumber" />
                                </TD>
								<TD WIDTH="1%">&nbsp;</TD>
								<TD WIDTH="13%">Type:</TD>
								<TD WIDTH="1%">&nbsp;</TD>
								<TD WIDTH="31%">
									<nested:hidden property="poTypeId" />
                                    <nested:write property="poTypeLabel" />

                                    <% if( request.getParameter("action") != null && request.getParameter("action").equalsIgnoreCase("edit") ) { %>
                                            &nbsp;&nbsp;&nbsp;<nested:checkbox property="poHold" styleClass="txfield" disabled="true"/> Hold
                                    <% } else if( request.getAttribute("action") != null && request.getAttribute("action").toString().equalsIgnoreCase("edit") ) { %>
                                            &nbsp;&nbsp;&nbsp;<nested:checkbox property="poHold" styleClass="txfield" disabled="true"/> Hold
                                    <% } else  { %>
                                           <nested:hidden property="poHold" value = "false"/>
                                    <% } %>
                                    <!--nested:hidden property="poHold" value = "false" /-->
                                </TD>
								<TD WIDTH="2%">&nbsp;</TD>
							</TR>
							<TR>
								<TD WIDTH="3%">&nbsp;</TD>
								<TD WIDTH="17%">Vendor Name:</TD>
								<TD WIDTH="1%">&nbsp;</TD>
								<TD WIDTH="31%">
                                    <nested:write property="vendorName" />
     							</TD>
								<TD WIDTH="1%">&nbsp;</TD>
								<TD WIDTH="13%">PO Date:</TD>
								<TD WIDTH="1%">&nbsp;</TD>
								<TD WIDTH="31%">
									<nested:write property="poDate" />
								</TD>
								<TD WIDTH="2%">&nbsp;</TD>
							</TR>
							<TR>
								<TD WIDTH="3%">&nbsp;</TD>
								<TD WIDTH="17%">Requistion Date:</TD>
								<TD WIDTH="1%">&nbsp;</TD>
								<TD WIDTH="31%">
                                    <nested:write property="requistionDate" />
     							</TD>
								<TD WIDTH="1%">&nbsp;</TD>
								<TD WIDTH="13%">Required Date:</TD>
								<TD WIDTH="1%">&nbsp;</TD>
								<TD WIDTH="31%">
									<nested:write property="requiredDate" />
								</TD>
								<TD WIDTH="2%">&nbsp;</TD>
							</TR>
							<TR>
								<TD WIDTH="3%">&nbsp;</TD>
								<TD WIDTH="17%">Promised Date:</TD>
								<TD WIDTH="1%">&nbsp;</TD>
								<TD WIDTH="31%">
                                    <nested:write property="promisedDate" />
     							</TD>
								<TD WIDTH="1%">&nbsp;</TD>
								<TD WIDTH="13%" nowrap>Promised Ship Date:</TD>
								<TD WIDTH="1%">&nbsp;</TD>
								<TD WIDTH="31%">
									<nested:write property="promisedShipDate" />
								</TD>
								<TD WIDTH="2%">&nbsp;</TD>
							</TR>
							<TR>
								<TD WIDTH="3%">&nbsp;</TD>
								<TD WIDTH="17%">Last Edited Date:</TD>
								<TD WIDTH="1%">&nbsp;</TD>
								<TD WIDTH="31%">
                                    <nested:write property="lastEditedDate" />
     							</TD>
								<TD WIDTH="1%">&nbsp;</TD>
								<TD WIDTH="13%">Last Released Date:</TD>
								<TD WIDTH="1%">&nbsp;</TD>
								<TD WIDTH="31%">
									<nested:write property="lastPrintedDate" />
								</TD>
								<TD WIDTH="2%">&nbsp;</TD>
							</TR>
							<TR>
								<TD WIDTH="3%">&nbsp;</TD>
		                        <nested:equal property = "poTypeId" value = "2">
								<TD WIDTH="17%">Customer Name:</TD>
								<TD WIDTH="1%">&nbsp;</TD>
								<TD WIDTH="31%">
                                    <nested:write property="customerName" />
                                </TD>
		                        </nested:equal>
		                        <nested:notEqual property = "poTypeId" value = "2">
								<TD WIDTH="17%">&nbsp;</TD>
								<TD WIDTH="1%">&nbsp;</TD>
								<TD WIDTH="31%">&nbsp;</TD>
		                        </nested:notEqual>
								<TD WIDTH="1%">&nbsp;</TD>
								<TD WIDTH="17%">PO Status:</TD>
								<TD WIDTH="1%">&nbsp;</TD>
								<TD WIDTH="31%">
									<nested:empty property="poStatusLabel">
										New
									</nested:empty>
									<nested:notEmpty property="poStatusLabel">
										<nested:write property="poStatusLabel" />
									</nested:notEmpty>
                                </TD>
								<TD WIDTH="2%">&nbsp;</TD>
							</TR>
							<!-- < n e s te d : e q u a l   p r o p e r t y   =   " p oT y p eI d "   v a lu e   =  " 2 " > -->
                            <!-- l og i c :eq u al   n a me = " a c t i o n "   v a l u e = " ed i t "  -->
                            <TR>
								<TD WIDTH="3%">&nbsp;</TD>
								<TD WIDTH="13%" nowrap>Ship To Address:</TD>
								
								<TD WIDTH="1%">&nbsp;</TD>
								<TD WIDTH="31%">
									<nested:write property="formattedShippingAddressAsHtml" filter="false" />
                                </TD>
								<TD WIDTH="48%" colspan="5">&nbsp;</TD>
							</TR>
							<!-- / l og i c : e qu a l  -->
							<!-- < / n e s t e d :e q u a l >  -->
						</TABLE>
                        <BR>
						<BR>

                        <TABLE BORDER="0" WIDTH="99%" CLASS="NArialL">
							<TR>
								<TD WIDTH="4%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
									<P ALIGN="CENTER">&nbsp;<FONT COLOR="white">Line Item</FONT>
								</TD>
								<TD WIDTH="10%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
									<P ALIGN="CENTER"><FONT COLOR="white">Part Number</FONT>
								</TD>
								<TD WIDTH="10%" HEIGHT="26" BGCOLOR="#993333">
									<P ALIGN="CENTER"><FONT COLOR="white">Vendor Part Number</FONT>
								</TD>
                                <TD WIDTH="10%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
									<P ALIGN="CENTER"><FONT COLOR="white">Description</FONT>
								</TD>
                                <!-- <TD WIDTH="10%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
									<P ALIGN="CENTER"><FONT COLOR="white">Site</FONT>
								</TD> -->
                                <TD WIDTH="10%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
									<P ALIGN="CENTER"><FONT COLOR="white">Required Date</FONT>
								</TD>

                                <TD WIDTH="10%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
									<P ALIGN="CENTER"><FONT COLOR="white">Promised Date</FONT>
								</TD>

								<TD WIDTH="10%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
									<P ALIGN="CENTER"><FONT COLOR="white">Requested Quantity</FONT>
								</TD>
								<TD WIDTH="10%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
									<P ALIGN="CENTER"><FONT COLOR="white">Quantity Cancelled</FONT>
								</TD>
								<TD WIDTH="10%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
									<P ALIGN="CENTER"><FONT COLOR="white">Unit Cost</FONT>
								</TD>
								<TD WIDTH="10%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
									<P ALIGN="CENTER"><FONT COLOR="white">Extended Cost</FONT>
								</TD>
                                <TD WIDTH="6%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
									<P ALIGN="CENTER"><FONT COLOR="white">Status</FONT>
								</TD>
								<!-- added by Phani on 23 March 2004 -->
								<TD WIDTH="6%" HEIGHT="26" ALIGN="CENTER" BGCOLOR="#993333">
									<P ALIGN="CENTER"><FONT COLOR="white">Cancel</FONT>
								</TD>


							</TR>
                            <nested:iterate id= "PurchaseOrderLineItem" property="purchaseOrderLineItemList" type="com.scalar.chiptrack.finance.purchaseorder.PurchaseOrderLineItem" >
							<TR>
								<TD WIDTH="4%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
									<P ALIGN="CENTER">&nbsp;
                                    <nested:write property="poIndex"/>
                                    <nested:hidden property="poIndex" />

                                    <nested:hidden property="poLineItemSequenceNo"/>
                                    <!-- Hidden field stores the no of Line items available for a Purchase Order -->
                                    <nested:hidden property="lineItemCount" />
								</TD>
								<TD WIDTH="10%" BGCOLOR="#DEE1E2">
									<P>
                                    <bean:define id="index" value="0"/>
                                    <nested:write property="marketingPartNo" />
								</TD>
								<TD WIDTH="10%" BGCOLOR="#DEE1E2">
									<P>
									<nested:write property="manufacturingPartNo" />
								</TD>
                                <TD WIDTH="10%" ALIGN="LEFT" BGCOLOR="#DEE1E2" HEIGHT="25"> 
									<P><nested:write property="lineItemDescription" />
								</TD>
                                <!-- <TD WIDTH="10%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
									<CENTER>
									<P>
                                    < n e s t e d :w r i te  p r o p  e r t y = " s i t e I d " />
                                    </CENTER>
								</TD> -->
                                <TD WIDTH="10%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
								<CENTER>
									<P><nested:write property="requiredDate" />
								</CENTER>
								</TD>

                                <TD WIDTH="10%" ALIGN="RIGHT" BGCOLOR="#DEE1E2">
								<CENTER>
									<P><nested:write property="promisedDate" />
								</CENTER>
								</TD>
                           
								<TD WIDTH="10%" ALIGN="RIGHT" BGCOLOR="#DEE1E2">
                                    <P><%= (int) ((PurchaseOrderLineItem)PurchaseOrderLineItem).getRequestedQuantity() %>
								</TD>
								<TD WIDTH="10%" ALIGN="RIGHT" BGCOLOR="#DEE1E2">
									<P><nested:write property="quantityCancelled" />
								</TD>

								<TD WIDTH="10%" ALIGN="RIGHT" BGCOLOR="#DEE1E2">
                                    <P><nested:hidden property="unitCost" />
                                    <nested:write property="unitCostAsString" />
                                </TD>
								<TD WIDTH="10%" ALIGN="RIGHT" BGCOLOR="#DEE1E2">
									<P><nested:hidden property="extendedCost" />
                                       <nested:write property="extendedCostAsString" />
								</TD>
                                <TD WIDTH="10%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
									<CENTER>
									<P>
                                    <nested:hidden property="poLineItemStatus" />
                                    <nested:write property="poLineItemStatusLabel" />
                                    </CENTER>
								</TD>
								<!-- added by Phani on 23 March 2004 -->
								<TD  WIDTH="10%" ALIGN="CENTER" BGCOLOR="#DEE1E2">
									<CENTER>
									<P>
									<nested:checkbox property="cancel" styleClass="txfield" disabled="true"/>
									
                                    </CENTER>
								</TD>

								
							</TR>
                            <% i++;%>
                            </nested:iterate>
                        <!--/TABLE>

						<TABLE BORDER="1" WIDTH="99%" CLASS="NArialL"-->
							<TR>
								<!--TD WIDTH="5%">&nbsp;</TD-->
								<TD colspan="6">&nbsp;</TD>
								<TD colspan="3" ALIGN="RIGHT">Subtotal:&nbsp;</TD>

								<TD width="10%" bgcolor="#DEE1E2" ALIGN="RIGHT">
                                    <nested:hidden property="subTotal" />
                                    <nested:write property="subTotalAsString" />
                                </TD>
                                <TD colspan="2" ALIGN="RIGHT">&nbsp;</TD>
								<!--TD WIDTH="20%">&nbsp;</TD-->
							</TR>
							<TR>
                                <!-- Commented on 11th Feb 04 -->
                                <!--TD WIDTH="27%" ALIGN="left">Remaining PO Subtotal:&nbsp;</TD-->
                                <TD colspan="6">&nbsp;</TD>
								<!--TD WIDTH="24%">
                                    <!--nested:hidden property="remainingPoSubTotal" />
                                    <!--nested:write property="remainingPoSubTotalAsString" />
                                </TD-->
                                <TD colspan="3" align="RIGHT">Trade&nbsp;Discount:&nbsp;</TD>

								<TD width="10%" bgcolor="#DEE1E2" ALIGN="RIGHT">
                                    <nested:hidden property="tradeDiscount" />
                                    <nested:write property="tradeDiscountAsString" />
                                </TD>
                                <TD colspan="2" ALIGN="RIGHT">&nbsp;</TD>
								<!--TD WIDTH="20%">&nbsp;</TD-->
							</TR>
							<TR>
                                <!-- Commented on 11th Feb 04 -->
								<!--TD WIDTH="27%" ALIGN="left">Purchase Addr Tax Schedule:&nbsp;</TD-->
                                <TD colspan="6">Comment:&nbsp;</TD>
								<!--TD WIDTH="24%">
									<!--nested:write property="purchaseAddressTaxScheduleId" />
								</TD-->
                                <TD colspan="3" ALIGN="RIGHT">Freight:&nbsp;</TD>


								<TD width="10%" bgcolor="#DEE1E2" ALIGN="RIGHT">
                                    <nested:hidden property="freight" />
                                    <nested:write property="freightAsString" />
                                </TD>
                                <TD colspan="2" ALIGN="RIGHT">&nbsp;</TD>
								<!--TD WIDTH="20%">&nbsp;</TD-->
							</TR>
							<TR>
								<TD colspan="6" rowspan="7" VALIGN="TOP">

                                    <nested:hidden property="commentId"/>
                                    <nested:textarea property="commentDescription" disabled="true" readonly="true" rows="6" cols="55"/>
                                </TD>
								<TD colspan="3" ALIGN="RIGHT">Miscellaneous:&nbsp;</TD>
								<TD width="10%" bgcolor="#DEE1E2" ALIGN="RIGHT">
                                    <nested:hidden property="miscellaneous" />
                                    <nested:write property="miscellaneousAsString" />
                                </TD>
                                <TD colspan="2"  ALIGN="RIGHT">&nbsp;</TD>
								<!--TD WIDTH="20%">&nbsp;</TD-->
							</TR>
							<TR>
								<TD colspan="3" ALIGN="RIGHT">Tax:&nbsp;</TD>
								<!-- <TD WIDTH="24%">&nbsp;</TD>  Because the row span is 3 in the above -->

								<TD width="10%" bgcolor="#DEE1E2" ALIGN="RIGHT">
                                    <nested:hidden property="tax" />
                                    <nested:write property="taxAsString" />
                                </TD>
                                <TD colspan="2" ALIGN="RIGHT">&nbsp;</TD>
								<!--TD WIDTH="20%">&nbsp;</TD-->
							</TR>
							<TR>
								<TD colspan="3" ALIGN="RIGHT">Total:&nbsp;</TD>
								<!-- <TD WIDTH="24%">&nbsp;</TD> Because the row span is 3 in the above -->

								<TD width="10%" bgcolor="#DEE1E2" ALIGN="RIGHT">
                                    <nested:hidden property="total" />
                                    <nested:write property="totalAsString" />
                                </TD>
                                <TD colspan="2" ALIGN="RIGHT">&nbsp;</TD>
								<!--TD WIDTH="20%">&nbsp;</TD-->
							</TR>
							<TR>
								<TD colspan="3">&nbsp;</TD>
								<TD width="10%">&nbsp;</TD>
								<TD colspan="2">&nbsp;</TD>
								<!--TD WIDTH="20%">&nbsp;</TD-->
							</TR>
							<TR>
								<TD colspan="3">&nbsp;</TD>
								<TD width="10%">&nbsp;</TD>
								<TD colspan="2">&nbsp;</TD>
								<!--TD WIDTH="20%">&nbsp;</TD-->
							</TR>
							<!--TR>
								<TD colspan="5">&nbsp;</TD>
							</TR-->
						</TABLE>
						<BR>
						<BR>
					</TD>
				</TR>
			</TABLE>
           </nested:nest>
		   <input type= "hidden" name = "count" value="<%=i%>"> <!-- added by Phani on 23 March March -->
           <input type="hidden" name="actiontype" value="<%=request.getAttribute("actiontype")%>"> <!--added by phani 27/04/04 -->
           </html:form>

					</TD>
				</TR>
				<TR>
					<TD WIDTH="100%">
						<TABLE BORDER="0" WIDTH="100%">
							<TR>
								<TD WIDTH="50%"><P ALIGN="RIGHT"><A href="javascript:savePO()" onmouseover="window.status='Click here To Save Purchase Order Details';return true" onmouseout="window.status='';return true"><IMG SRC="<%=chipTracContext%>/jsp/includes/images/confirm.gif"  VALIGN="BOTTOM" BORDER="0"></A></TD>
								<TD WIDTH="50%"><A href="javascript:editPO()"><IMG SRC="<%=chipTracContext%>/jsp/includes/images/edit.gif" VALIGN="BOTTOM" BORDER="0" onmouseover="window.status='Click here To Edit Purchase Order Details';return true" onmouseout="window.status='';return true"></A></TD>
							</TR>
						</TABLE>
					</TD>
				</TR>
			</TABLE>
<!-- Your Work area ends here -->
		</TD>
		<TD BGCOLOR="white"><IMG SRC="images/spacer.gif" WIDTH="1" HEIGHT="1" ALIGN="BOTTOM" BORDER="0"></TD>
	</TR>
</TBODY></TABLE>

<!-- Footer starts here -->

<%@include file="/jsp/includes/footer.jsp" %>

<!-- footer end here -->
</BODY>
</html:html>